package com.zjz.springcloud.service;

import com.zjz.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/06/8:01
 * @Description:
 * @Target:
 */

// 降级 ~
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long deptno) {
                return new Dept()
                        .setDeptno(deptno)
                        .setDname("deptno---->"+deptno+"没有对应的信息,客户端提供了降级的信息,这个服务现在已经被关闭了")
                        .setDb_source("没数据");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
